function[stat_mean]=mean_except_fillvalue(stat,fillvalue)
stat_length=0;
stat_sum=0;
stat_mean=0;
for i=1:length(stat)
    if stat(i)~=fillvalue
        stat_sum=stat_sum+stat(i);
        stat_length=stat_length+1;
    end
end
if stat_length==0
    stat_mean=fillvalue;
else
    stat_mean=stat_sum/stat_length;
end
end